.class public abstract Lcom/android/inputmethod/latin/VoiceKeyboardManager;
.super Ljava/lang/Object;
.source "VoiceKeyboardManager.java"


# static fields
.field static final DEBUG:Z = false

.field static ERROR_MESSAGES:[Ljava/lang/String; = null

.field static final GOOGLE:I = 0x1

.field static final SYSTEM_SETTINGS_KEY:Ljava/lang/String; = "voice_to_text"

.field static final TAG:Ljava/lang/String; = "###### VoiceKeyboardManager ######"

.field static final VLINGO:I


# instance fields
.field protected mBackupInputView:Landroid/view/View;

.field protected mContext:Lcom/android/inputmethod/latin/LatinIME;

.field private mEngineId:I

.field protected mHandler:Landroid/os/Handler;

.field protected mHideErrorMessageRunnable:Ljava/lang/Runnable;

.field protected mIsErrorMessageShown:Z

.field protected mIsVoiceKeyboardShown:Z

.field protected mSpeechEnded:Z

.field protected mVoiceKeyboardView:Landroid/view/View;


# direct methods
.method static constructor <clinit>()V
    .locals 3

    .prologue
    .line 52
    const/16 v0, 0xa

    new-array v0, v0, [Ljava/lang/String;

    const/4 v1, 0x0

    const-string v2, "Unknown error"

    aput-object v2, v0, v1

    const/4 v1, 0x1

    const-string v2, "Error, too much speech"

    aput-object v2, v0, v1

    const/4 v1, 0x2

    const-string v2, "Couldn\'t connect"

    aput-object v2, v0, v1

    const/4 v1, 0x3

    const-string v2, "Audio Problem"

    aput-object v2, v0, v1

    const/4 v1, 0x4

    const-string v2, "Server error"

    aput-object v2, v0, v1

    const/4 v1, 0x5

    const-string v2, "Voice search not installed"

    aput-object v2, v0, v1

    const/4 v1, 0x6

    const-string v2, "No speech heard"

    aput-object v2, v0, v1

    const/4 v1, 0x7

    const-string v2, "No matches found"

    aput-object v2, v0, v1

    const/16 v1, 0x8

    const-string v2, "Error. Please try again"

    aput-object v2, v0, v1

    const/16 v1, 0x9

    const-string v2, "Error, speech too short"

    aput-object v2, v0, v1

    sput-object v0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->ERROR_MESSAGES:[Ljava/lang/String;

    return-void
.end method

.method public constructor <init>(Lcom/android/inputmethod/latin/LatinIME;I)V
    .locals 3
    .parameter "context"
    .parameter "engineId"

    .prologue
    const/4 v2, 0x0

    .line 74
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 36
    const/4 v0, -0x1

    iput v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mEngineId:I

    .line 37
    new-instance v0, Landroid/os/Handler;

    invoke-static {}, Landroid/os/Looper;->getMainLooper()Landroid/os/Looper;

    move-result-object v1

    invoke-direct {v0, v1}, Landroid/os/Handler;-><init>(Landroid/os/Looper;)V

    iput-object v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mHandler:Landroid/os/Handler;

    .line 38
    iput-boolean v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mIsErrorMessageShown:Z

    .line 39
    new-instance v0, Lcom/android/inputmethod/latin/VoiceKeyboardManager$1;

    invoke-direct {v0, p0}, Lcom/android/inputmethod/latin/VoiceKeyboardManager$1;-><init>(Lcom/android/inputmethod/latin/VoiceKeyboardManager;)V

    iput-object v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mHideErrorMessageRunnable:Ljava/lang/Runnable;

    .line 47
    const/4 v0, 0x0

    iput-object v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mBackupInputView:Landroid/view/View;

    .line 48
    iput-boolean v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mIsVoiceKeyboardShown:Z

    .line 50
    iput-boolean v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mSpeechEnded:Z

    .line 75
    iput-object p1, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mContext:Lcom/android/inputmethod/latin/LatinIME;

    .line 76
    iput p2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mEngineId:I

    .line 77
    return-void
.end method

.method public static getInstanceByEngineId(Lcom/android/inputmethod/latin/LatinIME;I)Lcom/android/inputmethod/latin/VoiceKeyboardManager;
    .locals 1
    .parameter "context"
    .parameter "engineId"

    .prologue
    .line 67
    if-nez p1, :cond_0

    .line 68
    invoke-static {p0}, Lcom/android/inputmethod/latin/VlingoVoiceManager;->getInstance(Lcom/android/inputmethod/latin/LatinIME;)Lcom/android/inputmethod/latin/VlingoVoiceManager;

    move-result-object v0

    .line 70
    :goto_0
    return-object v0

    :cond_0
    invoke-static {p0}, Lcom/android/inputmethod/latin/GoogleVoiceManager;->getInstance(Lcom/android/inputmethod/latin/LatinIME;)Lcom/android/inputmethod/latin/GoogleVoiceManager;

    move-result-object v0

    goto :goto_0
.end method


# virtual methods
.method public abstract createVoiceKeyboardView()Landroid/view/View;
.end method

.method public getEngineId()I
    .locals 1

    .prologue
    .line 80
    iget v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mEngineId:I

    return v0
.end method

.method protected declared-synchronized hideVoiceKeyboard()V
    .locals 4

    .prologue
    .line 158
    monitor-enter p0

    :try_start_0
    iget-boolean v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mIsVoiceKeyboardShown:Z

    if-eqz v2, :cond_1

    iget-object v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mVoiceKeyboardView:Landroid/view/View;

    if-eqz v2, :cond_1

    iget-object v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mBackupInputView:Landroid/view/View;

    if-eqz v2, :cond_1

    .line 159
    iget-object v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mContext:Lcom/android/inputmethod/latin/LatinIME;

    invoke-virtual {v2}, Lcom/android/inputmethod/latin/LatinIME;->getWindow()Landroid/app/Dialog;

    move-result-object v2

    const v3, 0x102001e

    invoke-virtual {v2, v3}, Landroid/app/Dialog;->findViewById(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Landroid/widget/FrameLayout;

    .line 160
    .local v0, input_frame:Landroid/widget/FrameLayout;
    iget-object v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mVoiceKeyboardView:Landroid/view/View;

    invoke-virtual {v2}, Landroid/view/View;->getParent()Landroid/view/ViewParent;

    move-result-object v1

    check-cast v1, Landroid/widget/FrameLayout;

    .line 162
    .local v1, parent:Landroid/widget/FrameLayout;
    if-eq v0, v1, :cond_2

    .line 164
    const-string v2, "###### VoiceKeyboardManager ######"

    const-string v3, "The Input Frame is not the parent view?! Abort...."

    invoke-static {v2, v3}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    .line 165
    if-eqz v1, :cond_0

    .line 166
    iget-object v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mVoiceKeyboardView:Landroid/view/View;

    invoke-virtual {v1, v2}, Landroid/widget/FrameLayout;->removeView(Landroid/view/View;)V

    .line 171
    :cond_0
    :goto_0
    const/4 v2, 0x0

    iput-object v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mBackupInputView:Landroid/view/View;

    .line 172
    const/4 v2, 0x0

    iput-boolean v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mIsVoiceKeyboardShown:Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 174
    .end local v0           #input_frame:Landroid/widget/FrameLayout;
    .end local v1           #parent:Landroid/widget/FrameLayout;
    :cond_1
    monitor-exit p0

    return-void

    .line 169
    .restart local v0       #input_frame:Landroid/widget/FrameLayout;
    .restart local v1       #parent:Landroid/widget/FrameLayout;
    :cond_2
    :try_start_1
    iget-object v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mContext:Lcom/android/inputmethod/latin/LatinIME;

    iget-object v3, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mBackupInputView:Landroid/view/View;

    invoke-virtual {v2, v3}, Lcom/android/inputmethod/latin/LatinIME;->setInputView(Landroid/view/View;)V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    goto :goto_0

    .line 158
    .end local v0           #input_frame:Landroid/widget/FrameLayout;
    .end local v1           #parent:Landroid/widget/FrameLayout;
    :catchall_0
    move-exception v2

    monitor-exit p0

    throw v2
.end method

.method public isVoiceKeyboardShown()Z
    .locals 1

    .prologue
    .line 84
    iget-boolean v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mIsVoiceKeyboardShown:Z

    return v0
.end method

.method public onCancel()V
    .locals 0

    .prologue
    .line 96
    invoke-virtual {p0}, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->hideVoiceKeyboard()V

    .line 97
    return-void
.end method

.method public onConfigurationChanged()V
    .locals 1

    .prologue
    .line 88
    invoke-virtual {p0}, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->onCancel()V

    .line 89
    const/4 v0, 0x0

    iput-object v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mVoiceKeyboardView:Landroid/view/View;

    .line 90
    return-void
.end method

.method public onError(I)V
    .locals 2
    .parameter "error"

    .prologue
    .line 104
    if-lez p1, :cond_1

    const/16 v0, 0x9

    if-ge p1, v0, :cond_1

    .line 105
    const/4 v0, 0x1

    if-ne p1, v0, :cond_0

    iget-boolean v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mSpeechEnded:Z

    if-eqz v0, :cond_0

    .line 111
    const/4 p1, 0x2

    .line 113
    :cond_0
    sget-object v0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->ERROR_MESSAGES:[Ljava/lang/String;

    aget-object v0, v0, p1

    invoke-virtual {p0, v0}, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->showErrorMessage(Ljava/lang/String;)V

    .line 117
    :goto_0
    return-void

    .line 115
    :cond_1
    sget-object v0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->ERROR_MESSAGES:[Ljava/lang/String;

    const/4 v1, 0x0

    aget-object v0, v0, v1

    invoke-virtual {p0, v0}, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->showErrorMessage(Ljava/lang/String;)V

    goto :goto_0
.end method

.method public onFinish()V
    .locals 1

    .prologue
    const/4 v0, 0x0

    .line 129
    iput-object v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mContext:Lcom/android/inputmethod/latin/LatinIME;

    .line 130
    iput-object v0, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mVoiceKeyboardView:Landroid/view/View;

    .line 131
    return-void
.end method

.method public abstract showErrorMessage(Ljava/lang/String;)V
.end method

.method protected declared-synchronized showVoiceKeyboard()V
    .locals 3

    .prologue
    .line 138
    monitor-enter p0

    :try_start_0
    iget-object v1, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mVoiceKeyboardView:Landroid/view/View;

    if-nez v1, :cond_0

    .line 139
    invoke-virtual {p0}, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->createVoiceKeyboardView()Landroid/view/View;

    move-result-object v1

    iput-object v1, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mVoiceKeyboardView:Landroid/view/View;

    .line 142
    :cond_0
    iget-boolean v1, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mIsVoiceKeyboardShown:Z

    if-nez v1, :cond_2

    iget-object v1, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mVoiceKeyboardView:Landroid/view/View;

    if-eqz v1, :cond_2

    .line 143
    iget-object v1, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mContext:Lcom/android/inputmethod/latin/LatinIME;

    invoke-virtual {v1}, Lcom/android/inputmethod/latin/LatinIME;->getWindow()Landroid/app/Dialog;

    move-result-object v1

    const v2, 0x102001e

    invoke-virtual {v1, v2}, Landroid/app/Dialog;->findViewById(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Landroid/widget/FrameLayout;

    .line 144
    .local v0, input_frame:Landroid/widget/FrameLayout;
    const/4 v1, 0x0

    invoke-virtual {v0, v1}, Landroid/widget/FrameLayout;->getChildAt(I)Landroid/view/View;

    move-result-object v1

    iput-object v1, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mBackupInputView:Landroid/view/View;

    .line 145
    iget-object v1, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mVoiceKeyboardView:Landroid/view/View;

    invoke-virtual {v1}, Landroid/view/View;->getParent()Landroid/view/ViewParent;

    move-result-object v1

    if-eqz v1, :cond_1

    .line 146
    const-string v1, "###### VoiceKeyboardManager ######"

    const-string v2, "VoiceKeyboardView already has a parent?! Weird...."

    invoke-static {v1, v2}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    .line 147
    iget-object v1, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mVoiceKeyboardView:Landroid/view/View;

    invoke-virtual {v1}, Landroid/view/View;->getParent()Landroid/view/ViewParent;

    move-result-object v1

    check-cast v1, Landroid/view/ViewGroup;

    iget-object v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mVoiceKeyboardView:Landroid/view/View;

    invoke-virtual {v1, v2}, Landroid/view/ViewGroup;->removeView(Landroid/view/View;)V

    .line 149
    :cond_1
    iget-object v1, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mContext:Lcom/android/inputmethod/latin/LatinIME;

    iget-object v2, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mVoiceKeyboardView:Landroid/view/View;

    invoke-virtual {v1, v2}, Lcom/android/inputmethod/latin/LatinIME;->setInputView(Landroid/view/View;)V

    .line 150
    const/4 v1, 0x1

    iput-boolean v1, p0, Lcom/android/inputmethod/latin/VoiceKeyboardManager;->mIsVoiceKeyboardShown:Z
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 152
    .end local v0           #input_frame:Landroid/widget/FrameLayout;
    :cond_2
    monitor-exit p0

    return-void

    .line 138
    :catchall_0
    move-exception v1

    monitor-exit p0

    throw v1
.end method

.method public abstract startRecognition()V
.end method
